﻿@using MduiBlazor.Shared.Data
@inject WeatherForecastService ForecastService

<MduiTableContainer>
    <MduiTable Items="@forecasts">
        <HeaderContent>
            <MduiTh>Date</MduiTh>
            <MduiTh>TemperatureC</MduiTh>
            <MduiTh>TemperatureF</MduiTh>
            <MduiTh>Summary</MduiTh>
        </HeaderContent>
        <Columns>
            <MduiColumn>@context.Date.ToString("yyyy-MM-dd")</MduiColumn>
            <MduiColumn>@context.TemperatureC</MduiColumn>
            <MduiColumn>@context.TemperatureF</MduiColumn>
            <MduiColumn>@context.Summary</MduiColumn>
        </Columns>
    </MduiTable>
</MduiTableContainer>

@code {
    private IEnumerable<WeatherForecast>? forecasts;

    protected override async Task OnInitializedAsync()
    {
        forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
    }
}